package com.sky.mapper;

import com.sky.entity.ShoppingCart;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Update;
import org.springframework.web.bind.annotation.DeleteMapping;

import java.util.List;

/**
 * @author guozh
 */
@Mapper
public interface ShoppingCartMapper {
    /**
     * 查询购物车列表
     *
     * @param shoppingCart 购物车数据
     */
    List<ShoppingCart> selectShoppingCartList(ShoppingCart shoppingCart);

    /**
     * 更新购物车
     * @param shoppingCart 购物车数据
     */
    @Update("update shopping_cart set number = #{number} where id=#{id}")
    void updateShoppingCart(ShoppingCart shoppingCart);

    /**
     * 添加购物车
     * @param shoppingCart 购物车数据
     */
    @Insert("insert into shopping_cart (name, image, user_id, dish_id, setmeal_id, dish_flavor, amount, create_time) VALUES " +
            "(#{name},#{image},#{userId},#{dishId},#{setmealId},#{dishFlavor},#{amount},#{createTime})")
    void insertShoppingCart(ShoppingCart shoppingCart);
    /**
     * 清空购物车
     */
    @Delete("delete from shopping_cart where user_id = #{userId}")
    void deleteShoppingCartList(Long userId);
    /**
     * 删除购物车 一份数据
     * @param shoppingCart 删除的购物车数据
     */
    @Delete("delete from shopping_cart where id = #{id}")
    void deleteShoppingCart(ShoppingCart shoppingCart);

    /**
     * 批量插入购物车数据
     * @param shoppingCarts 购物车数据
     */
    void insertShoppingCartList(List<ShoppingCart> shoppingCarts);
}
